﻿/*
This file is under Microsoft Public License (MS-PL)
Copyright Yohann MARTEL.  All rights reserved.
Codeplex: http://amf.codeplex.com
AMF Website: http://www.ymartel.com/aspnet-mobile-framework/
*/
using System;
using System.ComponentModel;
using System.Web.UI;

namespace Mobile.WebControls
{
    public class Header : Div
    {
        #region Properties
        [Category("Functionality")]
        public bool AddBackButton { get; set; }
        [Category("Functionality")]
        public string BackButtonText { get; set; }
        [Category("Appearance")]
        public DataPosition Position { get; set; }
        #endregion

        #region Render Methods
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);
            writer.AddAttribute(MetadataAttribute.DataRole, DataRole.Header);
            if (AddBackButton)
            {
                writer.AddAttribute(MetadataAttribute.DataAddBackButton, Boolean.TrueString.ToLower());
                if (!String.IsNullOrEmpty(BackButtonText))
                {
                    writer.AddAttribute(MetadataAttribute.DataBackButtonText, BackButtonText);
                }
            }
            if (Position != DataPosition.Default)
            {
                writer.AddAttribute(MetadataAttribute.DataPosition, Enum.GetName(typeof(DataPosition),Position).ToLower());
            }
        }
        #endregion
    }
}
